import { createStore } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'
import user from '@/store/modules/user'
import cart from '@/store/modules/cart'
import category from '@/store/modules/category'

// vue2.0 创建仓库 new Vuex.Store({})
// vue3.0 创建仓库 createStore({})

export default createStore({
  modules: {
    cart,
    user,
    category
  },
  plugins: [ //  配置插件  vuex持久化  默认存储在localStorage
    createPersistedstate({
      //  本地存储名字
      key: 'erabbit-client-pc-124-store',
      //  指定需要存储的模块
      paths: ['user', 'cart']
    })
  ]
})
